package com.kt.app.ui.components


import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.clickable
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview

@Composable
fun PlusTextField() {
    var ctx = LocalContext.current
    var name by remember {
        mutableStateOf("")
    }
    TextField(
        value =name,
        onValueChange = {
            /*TODO*/
            Log.d("PlusTextField", "value: $it")
            name = it
        },
//        label = { Text("姓名") },
        leadingIcon = {Icon(imageVector = Icons.Filled.Person,  contentDescription = "")},
        placeholder = { Text("请输入姓名") },
        keyboardActions = KeyboardActions(
            onDone = {

                Toast.makeText(ctx, "Done ${name}", Toast.LENGTH_SHORT).show()
            }
        ),
        singleLine = true,
        keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done, keyboardType = KeyboardType.Text),

    )

}

@Preview
@Composable
fun PlusTextFieldPreview() {
    PlusTextField()
}

